package hu;

import java.util.Scanner;

public class word_search {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        int m = sc.nextInt();
        sc.nextLine();
        char[][] ch = new char[n][m];
        String word1 = sc.nextLine();
        char[] word = word1.toCharArray();
        for (int i = 0; i < n; i++) {
            String s = sc.nextLine();
            for (int j = 0; j < m; j++) {
                ch[i][j] = s.charAt(j);
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(ch[i][j] == word[0])
                {
                    int[][] used = new int[n][m];
                    if(trackBack(ch, word, i, j, 0, used)){
                        i++;
                        j++;
                        System.out.println(i + " " + j);
                        return;
                    }
                }
            }
        }
        System.out.println("no");
    }
    public static boolean trackBack(char[][] ch, char[] word, int i, int j, int index, int[][] used){
        if(index == word.length)
            return true;
        if(i < 0 || i >= ch.length || j < 0 || j >= ch[0].length || word[index] != ch[i][j] || used[i][j] == 1)
            return false;
        used[i][j] = 1;
        if(trackBack(ch, word, i + 1, j, index + 1, used))
            return true;
        if(trackBack(ch, word, i - 1, j, index + 1, used))
            return true;
        if(trackBack(ch, word, i, j + 1, index + 1, used))
            return true;
        if(trackBack(ch, word, i, j - 1, index + 1, used))
            return true;
        used[i][j] = 0;
        return false;
    }
}
/*
5 5
HELLOWORLD
CPUCY
EKLQH
CHELL
LROWO
DGRBC

5 5
HELLOWORLD
CPUCY
EKLQH
CHELL
LROWO
AGRBC
 */